home *** CD-ROM | disk | FTP | other *** search
-
- -- get the list of videofiles
- szScriptFolder = "Scripts/UIScreens/";
-
- -- Load Configuration
- Script:LoadScript(szScriptFolder.."UISystemCfg.lua", 1); -- Load Configuration File
-
- -- Load the skin
- Script:LoadScript(UI.szSkinPath, 1);
-
- UI.PageOptions=
- {
- GUI=
- {
-
- background=
- {
- classname = "static",
- left = 40, top = 150,
- width = 720, height = 300,
-
- color = UI.szMessageBoxScreenColor,
-
- zorder = -1, -- must be above all
- },
-
- -- ///////////////////////// Resolution /////////////////////////
-
- Resolution_text =
- {
- skin = UI.skins.Label,
- left = 45, top = 200,
- width = 150,
-
- fontname = "UI_Default_Bold",
-
- text = "Resolution",
- },
-
- Resolution =
- {
- left = 200, top = 200,
- skin = UI.skins.ComboBox, -- edit the skill to change the appearance. Skin.lua
-
- --buttoncolor = UI.szBorderColor,
-
- tabstop = 2,
-
- vscrollbar =
- {
- skin = UI.skins.VScrollBar,
- },
-
- fontname = "UI_Default",
-
- user =
- {
- -- data
- lScreenResolutionAndBpp = nil,
-
- -- code (implemented below)
- Initialize = nil,
- ApplySelection = nil,
- },
-
- OnChanged = function(self)
- if (self:GetSelection()) then
- System:Log("you've just selected: "..self:GetSelection());
- end
- end,
- },
-
- -- ///////////////////////// FSAA /////////////////////////
-
- FSAA_text =
- {
- skin = UI.skins.Label,
- left = 45, top = 242,
- width = 150,
-
- fontname = "UI_Default_Bold",
-
- text = "Anti Aliasing",
- },
-
- FSAA =
- {
- left = 200, top = 242,
- skin = UI.skins.ComboBox, -- edit the skill to change the appearance. Skin.lua
-
- tabstop = 3,
-
- fontname = "UI_Default",
-
- vscrollbar =
- {
- skin = UI.skins.VScrollBar,
- },
-
- OnChanged = function(self)
- if (self:GetSelection()) then
- System:Log("you've just selected: "..self:GetSelection());
- end
- end,
-
- user =
- {
- -- data
- initialSelectionIndex = 0,
-
- -- code (implemented below)
- Initialize = nil,
- UpdateAssignedGlobals = nil,
- },
- },
-
- -- ///////////////////////// Fullscreen /////////////////////////
-
- Fullscreen_text =
- {
- skin = UI.skins.Label,
- left = 45, top = 284,
- width = 150,
-
- fontname = "UI_Default_Bold",
-
- text = "Fullscreen Mode",
- },
-
- Fullscreen =
- {
- skin = UI.skins.CheckBox,
- left = 200, top = 284,
-
- tabstop = 4,
-
- -- code specific for "Full Screen" check box (separated in user table)
- user =
- {
- -- code (implemented below)
- UpdateAssignedGlobals = nil,
- },
- },
-
- -- ///////////////////////// 3Dc Texture Compression /////////////////////////
-
- TDCTexture_text =
- {
- skin = UI.skins.Label,
- left = 45, top = 326,
- width = 150,
-
- fontname = "UI_Default_Bold",
- text = "3Dc Texture Compression",
- },
-
- TDCTexture =
- {
- skin = UI.skins.CheckBox,
- left = 200, top = 326,
-
- tabstop = 5,
-
- user =
- {
- -- code (implemented below)
- UpdateAssignedGlobals = nil,
- },
- },
-
- -- ///////////////////////// VSync /////////////////////////
-
- VSync_text =
- {
- skin = UI.skins.Label,
- left = 45, top = 368,
- width = 152,
-
- fontname = "UI_Default_Bold",
- text = "Vertical Sync",
- },
-
- VSync =
- {
- skin = UI.skins.CheckBox,
- left = 200, top = 368,
-
- tabstop = 6,
-
- user =
- {
- -- code (implemented below)
- UpdateAssignedGlobals = nil,
- },
- },
-
- -- ///////////////////////// Sound Volume /////////////////////////
-
- SoundOnOff_text =
- {
- skin = UI.skins.Label,
- left = 360, top = 200,
- width = 150,
-
- fontname = "UI_Default_Bold",
- text = "Enable sound",
- },
-
- SoundOnOff =
- {
- skin = UI.skins.CheckBox,
- left = 515, top = 200,
-
- tabstop = 7,
-
- user =
- {
- -- code (implemented below)
- UpdateAssignedGlobals = nil,
- },
- },
-
- -- ///////////////////////// Sound Volume /////////////////////////
-
- SoundVolume_text =
- {
- skin = UI.skins.Label,
- left = 360, top = 242,
- width = 150,
-
- fontname = "UI_Default_Bold",
- text = "Sound Volume",
- },
-
- SoundVolume =
- {
- left = 515, top = 242,
- skin = UI.skins.HScrollBar, -- edit the skill to change the appearance. Skin.lua
-
- tabstop = 8,
-
- user =
- {
- soundSfxCue = Sound:LoadSound( "Sounds/Menu/Click.wav",SOUND_UNSCALABLE),
- },
-
- OnChanged = function( Sender )
- setglobal( "s_SFXVolume", Sender:GetValue() ); -- 0..1
- local sound = UI.PageOptions.GUI.SoundVolume.user.soundSfxCue;
- if( sound ~= nil ) then
- Sound:SetSoundVolume( sound, getglobal( "s_SFXVolume" ) * 255.0 );
- Sound:SetSoundLoop( sound, 0 );
- Sound:PlaySound( sound );
- end;
- end,
- },
-
- -- ------------------------- Apply -------------------------
-
- DoBenchmark=
- {
- skin = UI.skins.ActionButton, -- skin is like a template. it will inherit everything from it. Skin.lua
-
- left = 405, top = 540,
- tabstop = 1,
-
- fontname = "UI_Control",
- --fontsize = 14
- text = "Run Benchmark",
-
- OnCommand = function(self)
- local newValue = 0;
- local curValue = tonumber( getglobal( "r_Fullscreen" ) );
-
- if ( UI.PageOptions.GUI.Fullscreen:GetChecked() ) then
- newValue = 1;
- end
- if( newValue ~= curValue ) then
- setglobal( "r_Fullscreen", newValue );
- end
-
- newValue = 0;
- curValue = tonumber( getglobal( "r_Tex3DC" ) );
-
- if ( UI.PageOptions.GUI.TDCTexture:GetChecked() ) then
- newValue = 1;
- end
- if( newValue ~= curValue ) then
- setglobal( "r_Tex3DC", newValue );
- end
-
- newValue = 0;
- curValue = tonumber( getglobal( "r_VSync" ) );
-
- if ( UI.PageOptions.GUI.VSync:GetChecked() ) then
- newValue = 1;
- end
- if( newValue ~= curValue ) then
- setglobal( "r_VSync", newValue );
- end
-
- newValue = 0;
- curValue = tonumber( getglobal( "s_SoundEnable" ) );
-
- if ( UI.PageOptions.GUI.SoundOnOff:GetChecked() ) then
- newValue = 1;
- end
- if( newValue ~= curValue ) then
- setglobal( "s_SoundEnable", newValue );
- end
-
- UI.PageOptions.GUI.Resolution.user.ApplySelection();
- UI.PageOptions.GUI.FSAA.user.UpdateAssignedGlobals();
-
- TechDemo:GoToScreen( "Benchmark" );
- end,
- },
-
- Quit =
- {
- skin = UI.skins.ActionButton, -- skin is like a template. it will inherit everything from it. Skin.lua
-
- left = 580, top = 540,
- tabstop = 1,
-
- fontname = "UI_Control",
- --fontsize = 14
- text = "Quit",
-
- OnCommand = function(self)
- TechDemo:Quit();
- end,
- },
-
- OnInit = function(self)
- end,
-
- OnActivate= function(self) -- this will be called everytime you activate this screen
- -- here populate the screen
- self.Resolution:Clear();
- self.Resolution:AddItem("Blah"); -- there are lots of parameters you can add, such as background color, texture, etc.. etc..
-
- local curValue = tonumber( getglobal( "r_Fullscreen" ) );
- UI.PageOptions.GUI.Fullscreen:SetChecked( curValue ~= 0 );
-
- curValue = tonumber( getglobal( "r_VSync" ) );
- UI.PageOptions.GUI.VSync:SetChecked( curValue ~= 0 );
-
- curValue = tonumber( getglobal( "r_Tex3DC" ) );
- UI.PageOptions.GUI.TDCTexture:SetChecked( curValue ~= 0 );
-
- UI.PageOptions.GUI.SoundVolume:SetValue( getglobal("s_SFXVolume") );
-
- UI.PageOptions.GUI.Resolution.user.Initialize();
- UI.PageOptions.GUI.FSAA.user.Initialize();
- end,
- },
- };
-
- UI.PageOptions.GUI.Fullscreen.user.UpdateAssignedGlobals = function( self )
- local newValue = 0;
- local curValue = tonumber( getglobal( "r_Fullscreen" ) );
-
- if UI.PageOptions.GUI.Fullscreen:GetChecked() then
- newValue = 1;
- end
- if( newValue ~= curValue ) then
- setglobal( "r_Fullscreen", newValue );
- end
- end
-
-
-
- UI.PageOptions.GUI.TDCTexture.user.UpdateAssignedGlobals = function( self )
- local newValue = 0;
- local curValue = tonumber( getglobal( "r_Tex3DC" ) );
-
- if UI.PageOptions.GUI.TDCTexture:GetChecked() then
- newValue = 1;
- end
- if( newValue ~= curValue ) then
- setglobal( "r_Tex3DC", newValue );
- end
- end
-
-
-
- UI.PageOptions.GUI.VSync.user.UpdateAssignedGlobals = function( self )
- local newValue = 0;
- local curValue = tonumber( getglobal( "r_VSync" ) );
-
- if UI.PageOptions.GUI.VSync:GetChecked() then
- newValue = 1;
- end
- if( newValue ~= curValue ) then
- setglobal( "r_VSync", newValue );
- end
- end
-
-
- UI.PageOptions.GUI.Resolution.user.Initialize = function( self )
- -- initalize widget
- UI.PageOptions.GUI.Resolution:Clear();
-
- UI.PageOptions.GUI.Resolution.user.ScreenResolutionAndBpp = {};
- local lTmpScreenResolutionAndBpp = System:EnumDisplayFormats();
-
- local ref = UI.PageOptions.GUI.Resolution.user.ScreenResolutionAndBpp;
- local j = 1;
- for i, DispFmt in lTmpScreenResolutionAndBpp do
- if( DispFmt.bpp == 32 and DispFmt.width >= 1024 and DispFmt.height >= 768 ) then
- ref[ j ] = DispFmt;
- j = j + 1;
- end
- end
-
- for i, DispFmt in ref do
- UI.PageOptions.GUI.Resolution:AddItem( DispFmt.width.."x"..DispFmt.height.."x"..DispFmt.bpp );
- end
-
- -- let widget reflect state of globals
- local bpp = tonumber( getglobal( "r_ColorBits" ) );
- local sCurrentRes = tonumber( getglobal( "r_Width" ) ).."x"..tonumber( getglobal( "r_Height" ) ).."x"..bpp;
- UI.PageOptions.GUI.Resolution:Select( sCurrentRes );
- end
-
- UI.PageOptions.GUI.Resolution.user.ApplySelection = function( self )
-
- local index = UI.PageOptions.GUI.Resolution:GetSelectionIndex();
- local newRes = UI.PageOptions.GUI.Resolution.user.ScreenResolutionAndBpp[ index ];
-
- if( tostring( r_Width ) ~= tostring( newRes.width ) or
- tostring( r_Height )~= tostring( newRes.height ) or
- tostring( r_ColorBits ) ~= tostring( newRes.bpp ) ) then
-
- setglobal( "r_Width", newRes.width );
- setglobal( "r_Height", newRes.height );
- setglobal( "r_ColorBits", newRes.bpp );
-
- end
- end
-
-
- UI.PageOptions.GUI.FSAA.user.Initialize = function( self )
- -- initalize widget
- UI.PageOptions.GUI.FSAA:Clear();
-
- FSAAModes = System:EnumAAFormats();
-
- UI.PageOptions.GUI.FSAA:AddItem("None");
-
- UI.PageOptions.GUI.FSAA.user.FSAAModes = {};
-
- for n, mode in FSAAModes do
- local i = UI.PageOptions.GUI.FSAA:AddItem(mode.desc);
-
- UI.PageOptions.GUI.FSAA.user.FSAAModes[i] = mode;
- end
-
- -- let widget reflect state of globals
- local fsaa = tonumber(getglobal("r_FSAA" ));
- local fsaaSamples = tonumber(getglobal("r_FSAA_samples"));
- local fsaaQuality = tonumber(getglobal("r_FSAA_quality"));
- if(fsaa ~= 0) then
- -- find the correct match
- for n, mode in UI.PageOptions.GUI.FSAA.user.FSAAModes do
- if ((fsaaSamples == tonumber(mode.samples)) and (fsaaQuality == tonumber(mode.quality))) then
- UI.PageOptions.GUI.FSAA:SelectIndex(n);
- break;
- end
- end
- else
- UI.PageOptions.GUI.FSAA:SelectIndex(1);
- end;
-
- -- save initial selection state
- UI.PageOptions.GUI.FSAA.user.initialSelectionIndex =
- UI.PageOptions.GUI.FSAA:GetSelectionIndex();
-
- -- disable widget when game is running as FSAA can't be adjusted right now
- if( ClientStuff ) then
- UI:DisableWidget( UI.PageOptions.GUI.FSAA );
- end;
- end
-
- UI.PageOptions.GUI.FSAA.user.UpdateAssignedGlobals = function( self )
- local curSelectionIndex = UI.PageOptions.GUI.FSAA:GetSelectionIndex();
-
- -- has selection changed
- if( curSelectionIndex ~= UI.PageOptions.GUI.FSAA.user.initialSelectionIndex ) then
- if( curSelectionIndex == 1 ) then
- setglobal( "r_FSAA", 0 ); -- no fsaa
- setglobal( "r_FSAA_samples", 1 );
- setglobal( "r_FSAA_quality", 0 );
- else
- local mode = UI.PageOptions.GUI.FSAA.user.FSAAModes[curSelectionIndex];
- setglobal( "r_FSAA", 1 ); -- no fsaa
- setglobal( "r_FSAA_samples", mode.samples );
- setglobal( "r_FSAA_quality", mode.quality );
- end
- --System:LogToConsole( "FSAA mode and number of FSAA samples changed, relaunch necessary..." );
- --UI.PageOptions.GUI.relaunchNeeded = 1;
- UI.PageOptions.GUI.FSAA.user.initialSelectionIndex = curSelectionIndex;
- end
- end
-
- UI.PageOptions.GUI.SoundOnOff.user.UpdateAssignedGlobals = function( self )
- local newValue = 0;
- local curValue = tonumber( getglobal( "s_SoundEnable" ) );
-
- if UI.PageOptions.GUI.SoundOnOff:GetChecked() then
- newValue = 1;
- end
- if( newValue ~= curValue ) then
- setglobal( "s_SoundEnable", newValue );
- end
- end
-
- szScreen = "Options";
- UI:CreateScreenFromTable(szScreen, UI.PageOptions.GUI);
- Script:LoadScript("Scripts/UIScreens/UISystem.lua", 1);
-