Torque3D/Templates/BaseGame/game/data/ui/scripts/displayMenu.cs

245 lines
6.4 KiB
C#
Raw Normal View History

function DisplayMenu::loadSettings()
{
OptionsMenu.currentMenu = "DisplayMenu";
OptionsSettingStack.clear();
%APICount = getTokenCount(GraphicsDriverSetting::getList(),",");
if(%APICount > 1)
OptionsMenu.addSettingOption(OptionsSettingStack, "Diplay API", "", "GraphicsDriverSetting");
OptionsMenu.addSettingOption(OptionsSettingStack, "Screen Resolution", "", "ScreenResolutionSetting");
OptionsMenu.addSettingOption(OptionsSettingStack, "Fullscreen", "", "FullscreenSetting");
OptionsMenu.addSettingOption(OptionsSettingStack, "VSync", "", "VSyncSetting");
OptionsMenu.addSliderOption(OptionsSettingStack, "Field of View", $pref::Video::FOV, "65 120", 55, 75);
OptionsMenu.addSliderOption(OptionsSettingStack, "Brightness", $pref::Video::Brightness, "0 1", 10, 5);
OptionsMenu.addSliderOption(OptionsSettingStack, "Contrast", $pref::Video::Contrast, "0 1", 10, 5);
GraphicsSettingsCache.empty();
}
function DisplayMenu::apply(%this)
{
//Loop through the settings cache and actually apply the values
%cachedSettingCount = GraphicsSettingsCache.count();
for(%i=0; %i < %cachedSettingCount; %i++)
{
%var = GraphicsSettingsCache.getKey(%i);
%val = GraphicsSettingsCache.getValue(%i);
if(%var $= "$pref::Video::displayDevice")
{
MessageBoxOK( "Change requires restart", "Please restart the game for a display device change to take effect." );
}
setVariable(%var, %val);
}
//Update the display settings now
if (getWord( $pref::Video::Resolution, 2) == "")
{
$pref::Video::Resolution = getWord( $pref::Video::Resolution, 0 ) SPC getWord( $pref::Video::Resolution, 1 );
}
else
{
$pref::Video::Resolution = getWord( $pref::Video::Resolution, 0 ) SPC getWord( $pref::Video::Resolution, 2 );
}
/*if ( %newFullScreen $= "false" )
{
// If we're in windowed mode switch the fullscreen check
// if the resolution is bigger than the desktop.
%deskRes = getDesktopResolution();
%deskResX = getWord(%deskRes, $WORD::RES_X);
%deskResY = getWord(%deskRes, $WORD::RES_Y);
if ( getWord( %newRes, $WORD::RES_X ) > %deskResX ||
getWord( %newRes, $WORD::RES_Y ) > %deskResY )
{
$pref::Video::FullScreen = "true";
GraphicsMenuFullScreen.setStateOn( true );
}
}*/
// Build the final mode string.
%newMode = $pref::Video::Resolution SPC $pref::Video::FullScreen SPC 32 SPC $pref::Video::RefreshRate SPC $pref::Video::AA;
// Change the video mode.
/*if ( %newMode !$= $pref::Video::mode ||
%newVsync != $pref::Video::disableVerticalSync )
{
if ( %testNeedApply )
return true;*/
$pref::Video::mode = %newMode;
//$pref::Video::disableVerticalSync = %newVsync;
configureCanvas();
//}
echo("Exporting client prefs");
%prefPath = getPrefpath();
export("$pref::*", %prefPath @ "/clientPrefs.cs", false);
}
//
function GraphicsDriverSetting::set(%setting)
{
switch$(%setting)
{
case "D3D11":
GraphicsMenu::set("$pref::Video::displayDevice", "D3D11");
case "OpenGL":
GraphicsMenu::set("$pref::Video::displayDevice", "OpenGL");
default:
GraphicsMenu::set("$pref::Video::displayDevice", "OpenGL");
}
}
function GraphicsDriverSetting::get()
{
Moved unneeded modules to Templates/Modules Added templated getObjectsByClass to Scene for easier engine-side polling of objects, including nested checks for subscenes Proper init'ing of mGamemodeName in LevelAsset, as well as proper fieldType for mIsSubLevel D3D11 added logic to handle scaling down of textures in cubemap arrays for lower texture resolution preferences Added ability to collapse groups programmatically to GuiVariableInspector Upped PSSM shadowmap max size to 4096 Caught GL deferred lighting/probes up to D3D11 Temporarily disabled forward lighting/probes on GL materials until conversion finished Upped smMaxInstancingVerts to 2000 from 200 to support slightly more detailed meshes being instanced Reordered project settings so they load ahead of core modules, so that core modules can actually use project settings Established current preset file for PostFXManager to use for reverting WIP logic for forcing probes to update as part of level lighting load step in loading process Streamlined PostFXManager code, removing unnecessary/redundant files Coverted HDR, Lightrays and SSAO and ExamplePostEffect to use new PostFX Manager/Editor paradigm PostFX manager now enacts callbacks so that postFXs' can process their own settings as well as provide editor fields Changed PostFX editor to work with new callbacks via using VariableInspector Updated PostEffectAsset's template file so new PostFX's will now automatically register with the PostFXManager and have the needed new callbacks for integration Made HDR on by default, removed enable field from editing Made probe bake resolution a project setting Updated many GL postFX shaders to have proper case for PostFx.glsl Example module now loads ExampleGUI and ExamplePostEffect during init'ing Removed unneeded autoload definitions from ExampleModule's module file Fixed Graphics Adapter settings field to properly display as well as apply setting Updated many referenced profiles in tools folder to use the Tools specific gui profiles to make theming more consistent Fixed coloration of tools button bitmap to make theming more consistent Updated a few theme settings for improved visibility with theme, particularly selected/highlighted text Moved AssetBrowser field types to separated folder/files Updated new module creation to properly utilize template file instead of overriding it with a programmatic script generation. Removed unneded default autoload definitions from new modules Added WIP for editing Module/Asset dependencies Updated the PostEffectAsset to properly generate glsl and hlsl files from templates Updated module editor window to display only necessary fields Added WIP of TerrainAsset Added shaderCache gitignore file so folder isn't lost
2019-09-29 11:44:43 +00:00
if($pref::Video::displayDevice $= "D3D11")
return "D3D11";
Moved unneeded modules to Templates/Modules Added templated getObjectsByClass to Scene for easier engine-side polling of objects, including nested checks for subscenes Proper init'ing of mGamemodeName in LevelAsset, as well as proper fieldType for mIsSubLevel D3D11 added logic to handle scaling down of textures in cubemap arrays for lower texture resolution preferences Added ability to collapse groups programmatically to GuiVariableInspector Upped PSSM shadowmap max size to 4096 Caught GL deferred lighting/probes up to D3D11 Temporarily disabled forward lighting/probes on GL materials until conversion finished Upped smMaxInstancingVerts to 2000 from 200 to support slightly more detailed meshes being instanced Reordered project settings so they load ahead of core modules, so that core modules can actually use project settings Established current preset file for PostFXManager to use for reverting WIP logic for forcing probes to update as part of level lighting load step in loading process Streamlined PostFXManager code, removing unnecessary/redundant files Coverted HDR, Lightrays and SSAO and ExamplePostEffect to use new PostFX Manager/Editor paradigm PostFX manager now enacts callbacks so that postFXs' can process their own settings as well as provide editor fields Changed PostFX editor to work with new callbacks via using VariableInspector Updated PostEffectAsset's template file so new PostFX's will now automatically register with the PostFXManager and have the needed new callbacks for integration Made HDR on by default, removed enable field from editing Made probe bake resolution a project setting Updated many GL postFX shaders to have proper case for PostFx.glsl Example module now loads ExampleGUI and ExamplePostEffect during init'ing Removed unneeded autoload definitions from ExampleModule's module file Fixed Graphics Adapter settings field to properly display as well as apply setting Updated many referenced profiles in tools folder to use the Tools specific gui profiles to make theming more consistent Fixed coloration of tools button bitmap to make theming more consistent Updated a few theme settings for improved visibility with theme, particularly selected/highlighted text Moved AssetBrowser field types to separated folder/files Updated new module creation to properly utilize template file instead of overriding it with a programmatic script generation. Removed unneded default autoload definitions from new modules Added WIP for editing Module/Asset dependencies Updated the PostEffectAsset to properly generate glsl and hlsl files from templates Updated module editor window to display only necessary fields Added WIP of TerrainAsset Added shaderCache gitignore file so folder isn't lost
2019-09-29 11:44:43 +00:00
else if($pref::Video::displayDevice $= "OpenGL")
return "OpenGL";
else
return "Unknown";
}
function GraphicsDriverSetting::getList()
{
%returnsList = "";
%buffer = getDisplayDeviceList();
%deviceCount = getFieldCount( %buffer );
Moved unneeded modules to Templates/Modules Added templated getObjectsByClass to Scene for easier engine-side polling of objects, including nested checks for subscenes Proper init'ing of mGamemodeName in LevelAsset, as well as proper fieldType for mIsSubLevel D3D11 added logic to handle scaling down of textures in cubemap arrays for lower texture resolution preferences Added ability to collapse groups programmatically to GuiVariableInspector Upped PSSM shadowmap max size to 4096 Caught GL deferred lighting/probes up to D3D11 Temporarily disabled forward lighting/probes on GL materials until conversion finished Upped smMaxInstancingVerts to 2000 from 200 to support slightly more detailed meshes being instanced Reordered project settings so they load ahead of core modules, so that core modules can actually use project settings Established current preset file for PostFXManager to use for reverting WIP logic for forcing probes to update as part of level lighting load step in loading process Streamlined PostFXManager code, removing unnecessary/redundant files Coverted HDR, Lightrays and SSAO and ExamplePostEffect to use new PostFX Manager/Editor paradigm PostFX manager now enacts callbacks so that postFXs' can process their own settings as well as provide editor fields Changed PostFX editor to work with new callbacks via using VariableInspector Updated PostEffectAsset's template file so new PostFX's will now automatically register with the PostFXManager and have the needed new callbacks for integration Made HDR on by default, removed enable field from editing Made probe bake resolution a project setting Updated many GL postFX shaders to have proper case for PostFx.glsl Example module now loads ExampleGUI and ExamplePostEffect during init'ing Removed unneeded autoload definitions from ExampleModule's module file Fixed Graphics Adapter settings field to properly display as well as apply setting Updated many referenced profiles in tools folder to use the Tools specific gui profiles to make theming more consistent Fixed coloration of tools button bitmap to make theming more consistent Updated a few theme settings for improved visibility with theme, particularly selected/highlighted text Moved AssetBrowser field types to separated folder/files Updated new module creation to properly utilize template file instead of overriding it with a programmatic script generation. Removed unneded default autoload definitions from new modules Added WIP for editing Module/Asset dependencies Updated the PostEffectAsset to properly generate glsl and hlsl files from templates Updated module editor window to display only necessary fields Added WIP of TerrainAsset Added shaderCache gitignore file so folder isn't lost
2019-09-29 11:44:43 +00:00
%numAdapters = GFXInit::getAdapterCount();
%count = 0;
for(%i = 0; %i < %deviceCount; %i++)
{
%deviceDesc = getField(%buffer, %i);
if(%deviceDesc $= "GFX Null Device")
continue;
Moved unneeded modules to Templates/Modules Added templated getObjectsByClass to Scene for easier engine-side polling of objects, including nested checks for subscenes Proper init'ing of mGamemodeName in LevelAsset, as well as proper fieldType for mIsSubLevel D3D11 added logic to handle scaling down of textures in cubemap arrays for lower texture resolution preferences Added ability to collapse groups programmatically to GuiVariableInspector Upped PSSM shadowmap max size to 4096 Caught GL deferred lighting/probes up to D3D11 Temporarily disabled forward lighting/probes on GL materials until conversion finished Upped smMaxInstancingVerts to 2000 from 200 to support slightly more detailed meshes being instanced Reordered project settings so they load ahead of core modules, so that core modules can actually use project settings Established current preset file for PostFXManager to use for reverting WIP logic for forcing probes to update as part of level lighting load step in loading process Streamlined PostFXManager code, removing unnecessary/redundant files Coverted HDR, Lightrays and SSAO and ExamplePostEffect to use new PostFX Manager/Editor paradigm PostFX manager now enacts callbacks so that postFXs' can process their own settings as well as provide editor fields Changed PostFX editor to work with new callbacks via using VariableInspector Updated PostEffectAsset's template file so new PostFX's will now automatically register with the PostFXManager and have the needed new callbacks for integration Made HDR on by default, removed enable field from editing Made probe bake resolution a project setting Updated many GL postFX shaders to have proper case for PostFx.glsl Example module now loads ExampleGUI and ExamplePostEffect during init'ing Removed unneeded autoload definitions from ExampleModule's module file Fixed Graphics Adapter settings field to properly display as well as apply setting Updated many referenced profiles in tools folder to use the Tools specific gui profiles to make theming more consistent Fixed coloration of tools button bitmap to make theming more consistent Updated a few theme settings for improved visibility with theme, particularly selected/highlighted text Moved AssetBrowser field types to separated folder/files Updated new module creation to properly utilize template file instead of overriding it with a programmatic script generation. Removed unneded default autoload definitions from new modules Added WIP for editing Module/Asset dependencies Updated the PostEffectAsset to properly generate glsl and hlsl files from templates Updated module editor window to display only necessary fields Added WIP of TerrainAsset Added shaderCache gitignore file so folder isn't lost
2019-09-29 11:44:43 +00:00
for( %i = 0; %i < %numAdapters; %i ++ )
{
if( GFXInit::getAdapterName( %i ) $= %deviceDesc )
{
%deviceName = GFXInit::getAdapterType( %i );
break;
}
}
if(%count != 0)
Moved unneeded modules to Templates/Modules Added templated getObjectsByClass to Scene for easier engine-side polling of objects, including nested checks for subscenes Proper init'ing of mGamemodeName in LevelAsset, as well as proper fieldType for mIsSubLevel D3D11 added logic to handle scaling down of textures in cubemap arrays for lower texture resolution preferences Added ability to collapse groups programmatically to GuiVariableInspector Upped PSSM shadowmap max size to 4096 Caught GL deferred lighting/probes up to D3D11 Temporarily disabled forward lighting/probes on GL materials until conversion finished Upped smMaxInstancingVerts to 2000 from 200 to support slightly more detailed meshes being instanced Reordered project settings so they load ahead of core modules, so that core modules can actually use project settings Established current preset file for PostFXManager to use for reverting WIP logic for forcing probes to update as part of level lighting load step in loading process Streamlined PostFXManager code, removing unnecessary/redundant files Coverted HDR, Lightrays and SSAO and ExamplePostEffect to use new PostFX Manager/Editor paradigm PostFX manager now enacts callbacks so that postFXs' can process their own settings as well as provide editor fields Changed PostFX editor to work with new callbacks via using VariableInspector Updated PostEffectAsset's template file so new PostFX's will now automatically register with the PostFXManager and have the needed new callbacks for integration Made HDR on by default, removed enable field from editing Made probe bake resolution a project setting Updated many GL postFX shaders to have proper case for PostFx.glsl Example module now loads ExampleGUI and ExamplePostEffect during init'ing Removed unneeded autoload definitions from ExampleModule's module file Fixed Graphics Adapter settings field to properly display as well as apply setting Updated many referenced profiles in tools folder to use the Tools specific gui profiles to make theming more consistent Fixed coloration of tools button bitmap to make theming more consistent Updated a few theme settings for improved visibility with theme, particularly selected/highlighted text Moved AssetBrowser field types to separated folder/files Updated new module creation to properly utilize template file instead of overriding it with a programmatic script generation. Removed unneded default autoload definitions from new modules Added WIP for editing Module/Asset dependencies Updated the PostEffectAsset to properly generate glsl and hlsl files from templates Updated module editor window to display only necessary fields Added WIP of TerrainAsset Added shaderCache gitignore file so folder isn't lost
2019-09-29 11:44:43 +00:00
%returnsList = %returnsList @ "," @ %deviceName;
else
Moved unneeded modules to Templates/Modules Added templated getObjectsByClass to Scene for easier engine-side polling of objects, including nested checks for subscenes Proper init'ing of mGamemodeName in LevelAsset, as well as proper fieldType for mIsSubLevel D3D11 added logic to handle scaling down of textures in cubemap arrays for lower texture resolution preferences Added ability to collapse groups programmatically to GuiVariableInspector Upped PSSM shadowmap max size to 4096 Caught GL deferred lighting/probes up to D3D11 Temporarily disabled forward lighting/probes on GL materials until conversion finished Upped smMaxInstancingVerts to 2000 from 200 to support slightly more detailed meshes being instanced Reordered project settings so they load ahead of core modules, so that core modules can actually use project settings Established current preset file for PostFXManager to use for reverting WIP logic for forcing probes to update as part of level lighting load step in loading process Streamlined PostFXManager code, removing unnecessary/redundant files Coverted HDR, Lightrays and SSAO and ExamplePostEffect to use new PostFX Manager/Editor paradigm PostFX manager now enacts callbacks so that postFXs' can process their own settings as well as provide editor fields Changed PostFX editor to work with new callbacks via using VariableInspector Updated PostEffectAsset's template file so new PostFX's will now automatically register with the PostFXManager and have the needed new callbacks for integration Made HDR on by default, removed enable field from editing Made probe bake resolution a project setting Updated many GL postFX shaders to have proper case for PostFx.glsl Example module now loads ExampleGUI and ExamplePostEffect during init'ing Removed unneeded autoload definitions from ExampleModule's module file Fixed Graphics Adapter settings field to properly display as well as apply setting Updated many referenced profiles in tools folder to use the Tools specific gui profiles to make theming more consistent Fixed coloration of tools button bitmap to make theming more consistent Updated a few theme settings for improved visibility with theme, particularly selected/highlighted text Moved AssetBrowser field types to separated folder/files Updated new module creation to properly utilize template file instead of overriding it with a programmatic script generation. Removed unneded default autoload definitions from new modules Added WIP for editing Module/Asset dependencies Updated the PostEffectAsset to properly generate glsl and hlsl files from templates Updated module editor window to display only necessary fields Added WIP of TerrainAsset Added shaderCache gitignore file so folder isn't lost
2019-09-29 11:44:43 +00:00
%returnsList = %deviceName;
%count++;
}
return %returnsList;
}
//
function ScreenResolutionSetting::set(%setting)
{
GraphicsMenu::set("$pref::Video::Resolution", %setting);
}
function ScreenResolutionSetting::get()
{
return _makePrettyResString( $pref::Video::Resolution );
}
function ScreenResolutionSetting::getList()
{
%returnsList = "";
%resCount = Canvas.getModeCount();
for (%i = 0; %i < %resCount; %i++)
{
%testResString = Canvas.getMode( %i );
%testRes = _makePrettyResString( %testResString );
//sanitize
%found = false;
%retCount = getTokenCount(%returnsList, ",");
for (%x = 0; %x < %retCount; %x++)
{
%existingEntry = getToken(%returnsList, ",", %x);
if(%existingEntry $= %testRes)
{
%found = true;
break;
}
}
if(%found)
continue;
if(%i != 0)
%returnsList = %returnsList @ "," @ %testRes;
else
%returnsList = %testRes;
}
return %returnsList;
}
//
function FullscreenSetting::set(%setting)
{
switch$(%setting)
{
case "On":
GraphicsMenu::set("$pref::Video::FullScreen", "1");
case "Off":
GraphicsMenu::set("$pref::Video::FullScreen", "0");
default:
GraphicsMenu::set("$pref::Video::FullScreen", "0");
}
}
function FullscreenSetting::get()
{
if($pref::Video::FullScreen == 1)
return "On";
else if($pref::Video::FullScreen == 0)
return "Off";
else
return "Custom";
}
function FullscreenSetting::getList()
{
return "Off,On";
}
//
function VSyncSetting::set(%setting)
{
switch$(%setting)
{
case "On":
GraphicsMenu::set("$pref::Video::disableVerticalSync", "0");
case "Off":
GraphicsMenu::set("$pref::Video::disableVerticalSync", "1");
default:
GraphicsMenu::set("$pref::Video::disableVerticalSync", "1");
}
}
function VSyncSetting::get()
{
if($pref::Video::disableVerticalSync == 0)
return "On";
else if($pref::Video::disableVerticalSync == 1)
return "Off";
else
return "Custom";
}
function VSyncSetting::getList()
{
return "Off,On";
}