00001 //===========================================================================
00002 // Video Options
00003 //===========================================================================
00004 class XIIIMenuVideoClientWindow extends XIIIWindow
00005 config(user);
00006
00007 // Brightness, Gamma, Contrast
00008 VAR XIIIHSliderControl BrightnessSlider, GammaSlider, ContrastSlider, HCenterSlider, VCenterSlider;
00009 VAR XIIIComboControl ResCombo;//, DepthCombo;
00010 VAR XIIIButton DefaultButton;
00011 var localized string TitleText, BrightnessText, GammaText, ContrastText, DefaultText;
00012 var localized string CenterText, HCenterText, VCenterText, ResText, DepthText;
00013
00014 var texture tBackground[4], tCenter, tHighlight;
00015 var string sBackground[4], sCenter;
00016
00017 var int OnBright, OnGamma, OnContrast, OnRes, YOrg, LineSpace, oldDecalX, oldDecalY;
00018 var config int DecalX, DecalY; // better be moved to LevelInfo
00019 var config float UserBrightness, UserContrast, UserGamma;
00020 var float OldBright, OldGamma, OldContrast;
00021 var bool bInitialized;
00022 var string OldSettings;
00023
00024
00025 function Created()
00026 {
00027 LOCAL int i, MinRate, temp, CtrlIndex, nbItems;
00028 LOCAL string NextLook, NextDesc, NewVideoMode;
00029 LOCAL array<levelinfo.resinfo> videomodes;
00030
00031 Super.Created();
00032
00033 switch ( myRoot.CurrentPF )
00034 {
00035 case 0: // PC
00036 nbItems=5; // Brightness, Gamma, Contrast & Resolution + Default
00037 break;
00038 case 2: // XBox
00039 nbItems=4; // Brightness, Gamma & Contrast + Default
00040 break;
00041 case 1: // PS2
00042 case 3: // GCube
00043 oldDecalX = DecalX;
00044 oldDecalY = DecalY;
00045 // myRoot.GetLevel().DecalScreen(0, DecalX);
00046 // myRoot.GetLevel().DecalScreen(1, DecalY);
00047 nbItems=2; // centrage X & Y
00048 break;
00049 }
00050
00051 LineSpace=29+(370-(nbItems*29))/(nbItems+1);
00052 YOrg=27+LineSpace;
00053
00054 tHighlight = texture(DynamicLoadObject("XIIIMenuStart.barreselectmenuoptadv", class'Texture'));
00055
00056 tBackGround[0] = texture(DynamicLoadObject(sBackGround[0], class'Texture'));
00057 tBackGround[1] = texture(DynamicLoadObject(sBackGround[1], class'Texture'));
00058 tBackGround[2] = texture(DynamicLoadObject(sBackGround[2], class'Texture'));
00059 tBackGround[3] = texture(DynamicLoadObject(sBackGround[3], class'Texture'));
00060 tCenter = texture(DynamicLoadObject(sCenter, class'Texture'));
00061
00062 if ( myRoot.CurrentPF==0 || myRoot.CurrentPF==2 ) // PC ou XBox
00063 {
00064 // Brightness
00065 BrightnessSlider = XIIIHSliderControl(CreateControl(class'XIIIHSliderControl', 308, YOrg*fScaleTo, 300, 29*fScaleTo));
00066 BrightnessSlider.SetRange(0, 10, 1, 150);
00067 OnBright = int( UserBrightness * 10 );
00068 BrightnessSlider.SetValue(OnBright);
00069 BrightnessSlider.Text = BrightnessText;
00070 BrightnessSlider.OnChange = BrightnessChanged;
00071 Controls[CtrlIndex] = BrightnessSlider;
00072 CtrlIndex++;
00073
00074 // Gamma
00075 GammaSlider = XIIIHSliderControl(CreateControl(class'XIIIHSliderControl', 308, (YOrg+LineSpace)*fScaleTo, 300, 29*fScaleTo));
00076 GammaSlider.SetRange(5, 15, 1, 150);
00077 OnGamma = int( UserGamma * 10);
00078 GammaSlider.SetValue(OnGamma);
00079 GammaSlider.Text = GammaText;
00080 GammaSlider.OnChange = GammaChanged;
00081 Controls[CtrlIndex] = GammaSlider;
00082 CtrlIndex++;
00083
00084 // Contrast
00085 ContrastSlider = XIIIHSliderControl(CreateControl(class'XIIIHSliderControl', 308, (YOrg+LineSpace*CtrlIndex)*fScaleTo, 300, 29*fScaleTo));
00086 ContrastSlider.SetRange(0, 10, 1, 150);
00087 OnContrast = int( UserContrast * 10);
00088 ContrastSlider.SetValue(OnContrast);
00089 ContrastSlider.Text = ContrastText;
00090 ContrastSlider.OnChange = ContrastChanged;
00091 Controls[CtrlIndex] = ContrastSlider;
00092 CtrlIndex++;
00093
00094 if ( myRoot.CurrentPF==0 ) // PC Only
00095 {
00096 ResCombo = XIIIComboControl(CreateControl(class'XIIIComboControl', 308, (YOrg+LineSpace*3)*fScaleTo, 300, 29*fScaleTo));
00097
00098 myRoot.Getlevel().GETAVAILABLERES(videomodes);
00099 for (i=0; i<videomodes.length; i++)
00100 {
00101 NewVideoMode=string(videomodes[i].PixelWidth)$"x"$string(videomodes[i].PixelHeight);
00102 ResCombo.AddItem(NewVideoMode);
00103 log ("===>"@NewVideoMode );
00104 }
00105 OnRes = ResCombo.FindItemIndex(myRoot.GetPlayerOwner().ConsoleCommand( "GETCURRENTRES" ));
00106 ResCombo.SetSelectedIndex(OnRes);
00107 ResCombo.Text = ResText;
00108 ResCombo.bArrows = true;
00109 Controls[CtrlIndex] = ResCombo;
00110 CtrlIndex++;
00111 }
00112
00113 // Default button
00114 DefaultButton = XIIIbutton( CreateControl(class'XIIIbutton', 408, (YOrg+LineSpace*CtrlIndex)*fScaleTo, 100, 29) );
00115 DefaultButton.Text = DefaultText;
00116 DefaultButton.bUseBorder = true;
00117 Controls[CtrlIndex] = DefaultButton;
00118 CtrlIndex++;
00119 }
00120 else // PS2 && Cube
00121 {
00122 HCenterSlider = XIIIHSliderControl(CreateControl(class'XIIIHSliderControl', 308, (YOrg)*fScaleTo, 300, 29*fScaleTo));
00123 HCenterSlider.SetRange(-10, 10, 1, 150);
00124 HCenterSlider.Text = HCenterText;
00125 HCenterSlider.SetValue(DecalX);
00126 Controls[CtrlIndex] = HCenterSlider;
00127 CtrlIndex++;
00128
00129 VCenterSlider = XIIIHSliderControl(CreateControl(class'XIIIHSliderControl', 308, (YOrg+LineSpace)*fScaleTo, 300, 29*fScaleTo));
00130 VCenterSlider.SetRange(-10, 10, 1, 150);
00131 VCenterSlider.Text = VCenterText;
00132 VCenterSlider.SetValue(DecalY);
00133 Controls[CtrlIndex] = VCenterSlider;
00134 CtrlIndex++;
00135 }
00136 }
00137
00138 function ShowWindow()
00139 {
00140 OldBright = UserBrightness;
00141 OldGamma = UserGamma;
00142 OldContrast = UserContrast;
00143
00144 BrightnessSlider.SetValue(OnBright);
00145 GammaSlider.SetValue(OnGamma);
00146 ContrastSlider.SetValue(OnContrast);
00147
00148 if (myRoot.CurrentPF == 0)
00149 {
00150 OnRes = ResCombo.FindItemIndex(myRoot.GetPlayerOwner().ConsoleCommand( "GETCURRENTRES" ));
00151 ResCombo.SetSelectedIndex(OnRes);
00152 }
00153 Super.ShowWindow();
00154 bShowCCL = true;
00155 bShowACC = true;
00156 }
00157
00158
00159 function Paint(Canvas C, float X, float Y)
00160 {
00161 local float fScale, fHeight, W, H;
00162
00163 Super.Paint(C, X, Y);
00164
00165 CONST ImageW=350;
00166 CONST ImageH=370;
00167
00168 fHeight = fScaleTo;//myRoot.ScreenHeight/480;
00169 if (myRoot.CurrentPF > 0) fHeight = 0.95;
00170 fHeight= (fHeight*416) / 2;
00171 DrawStretchedTexture(C, (610-ImageW-2)*fRatioX, ( 425 - ImageH - 2 )*fScaleTo*fRatioY, (ImageW+4)*fRatioX, (ImageH+4)*fRatioY*fScaleTo, myRoot.tFondNoir);
00172
00173 DrawStretchedTexture(C, (610-ImageW)*fRatioX, ( 425 - ImageH )*fScaleTo*fRatioY, ImageW*fRatioX, 370*fScaleTo*fRatioY, tBackGround[0]);
00174
00175 OnMenu = FindComponentIndex(FocusedControl);
00176 C.Style = 5;
00177 C.DrawColor.A = 180;
00178 DrawStretchedTexture(C, (610-ImageW)*fRatioX, ((Yorg-5+OnMenu*LineSpace)*fScaleTo)*fRatioY, ImageW*fRatioX, 40*fRatioY, tHighlight);
00179 C.DrawColor.A = 255;
00180
00181 DrawStretchedTexture(C, (610-ImageW-130)*fRatioX, ( 448 - 192 )*fScaleTo*fRatioY, 192*fRatioX, 192*fScaleTo*fRatioY, tBackGround[2]);
00182 DrawStretchedTexture(C, (610-ImageW-130)*fRatioX, ( 448 - 192 - 192 )*fScaleTo*fRatioY, 192*fRatioX, 192*fScaleTo*fRatioY, tBackGround[1]);
00183 DrawStretchedTexture(C, (610-192-ImageW-130)*fRatioX, ( 448 - 192 )*fScaleTo*fRatioY, 192*fRatioX, 192*fScaleTo*fRatioY, tBackGround[3]);
00184
00185 C.Style = 1;
00186
00187 C.bUseBorder = true;
00188 DrawStretchedTexture(C, 150*fRatioX, 30*fRatioY, 170*fRatioX, 35*fRatioY, myRoot.FondMenu);
00189 C.TextSize(TitleText, W, H);
00190 C.DrawColor = BlackColor;
00191 C.SetPos((150 + (160-W)/2)*fRatioX, (47.5-H/2)*fRatioY);
00192 C.DrawText(TitleText, false);
00193 C.bUseBorder = false;
00194 C.DrawColor = WhiteColor;
00195 }
00196
00197
00198 function bool InternalOnKeyEvent(out byte Key, out byte State, float delta)
00199 {
00200 local int i;
00201
00202 if ((State==1) || (State==2))// IST_Press // to avoid auto-repeat
00203 {
00204 if ( Key==0x0D || Key==0x01 )
00205 {
00206 if ( FocusedControl==DefaultButton)
00207 {
00208 BrightnessSlider.SetValue(5);
00209 GammaSlider.SetValue(10);
00210 ContrastSlider.SetValue(5);
00211 BrightnessChanged( BrightnessSlider );
00212 GammaChanged( GammaSlider );
00213 ContrastChanged( ContrastSlider );
00214 return true;
00215 }
00216 }
00217
00218 if ( Key==0x0D/*IK_Enter*/ )
00219 {
00220 ConfirmSettings();
00221 if ( myRoot.CurrentPF == 0 )
00222 GetPlayerOwner().ConsoleCommand("SETRES"@ResCombo.GetValue());
00223 // SaveConfigs();
00224 SaveConfig();
00225 myRoot.CloseMenu(false);
00226 Controller.FocusedControl.OnClick(Self);
00227 return true;
00228 }
00229 if ((Key==0x08/*IK_Backspace*/)|| (Key==0x1B))
00230 {
00231 GetPlayerOwner().ConsoleCommand("Brightness "$OldBright);
00232 GetPlayerOwner().ConsoleCommand("Gamma "$OldGamma);
00233 GetPlayerOwner().ConsoleCommand("Contrast "$OldContrast);
00234 if ( ( myRoot.CurrentPF == 1 ) || ( myRoot.CurrentPF == 3 ) )
00235 {
00236 myRoot.GetLevel().DecalScreen(0, oldDecalX-DecalX);
00237 myRoot.GetLevel().DecalScreen(1, oldDecalY-DecalY);
00238 DecalX = oldDecalX;
00239 DecalY = oldDecalY;
00240 }
00241 myRoot.CloseMenu(true);
00242 return true;
00243 }
00244 if (Key==0x26/*IK_Up*/)
00245 {
00246 PrevControl(FocusedControl);
00247 return true;
00248 }
00249 if (Key==0x28/*IK_Down*/)
00250 {
00251 NextControl(FocusedControl);
00252 return true;
00253 }
00254 if ((Key==0x25) || (Key==0x27))
00255 {
00256 if ( FocusedControl==BrightnessSlider )
00257 {
00258 BrightnessChanged( BrightnessSlider );
00259 }
00260 else if ( FocusedControl==GammaSlider )
00261 {
00262 GammaChanged( GammaSlider );
00263 }
00264 else if ( FocusedControl==ContrastSlider )
00265 {
00266 ContrastChanged( ContrastSlider );
00267 }
00268 else if ( FocusedControl == ResCombo )
00269 {
00270 if ( Key==0x25 ) OnRes--;
00271 if ( Key==0x27 ) OnRes++;
00272 OnRes = Clamp( OnRes,0,ResCombo.Items.Length-1);
00273 ResCombo.SetSelectedIndex(OnRes);
00274 }
00275 else if ( FocusedControl == HCenterSlider)
00276 {
00277 if (Key==0x25 && DecalX!=-10) { myRoot.GetLevel().DecalScreen(0, -1); DecalX--; }
00278 if (Key==0x27 && DecalX!=10) { myRoot.GetLevel().DecalScreen(0, 1); DecalX++; }
00279 }
00280 else if ( FocusedControl == VCenterSlider)
00281 {
00282 if (Key==0x25 && DecalY!=-10) { myRoot.GetLevel().DecalScreen(1, -1); DecalY--; }
00283 if (Key==0x27 && DecalY!=10) { myRoot.GetLevel().DecalScreen(1, 1); DecalY++; }
00284 }
00285 return true;
00286 }
00287 }
00288 return super.InternalOnKeyEvent(Key, state, delta);
00289 }
00290
00291
00292 function ConfirmSettings()
00293 {
00294 if ( myRoot.CurrentPF==0 || myRoot.CurrentPF==2 )
00295 {
00296 UserBrightness = BrightnessSlider.GetValue() * 0.1;
00297 UserGamma = GammaSlider.GetValue() * 0.1;
00298 UserContrast = ContrastSlider.GetValue() * 0.1;
00299 BrightnessChanged( BrightnessSlider );
00300 ContrastChanged( ContrastSlider );
00301 GammaChanged( GammaSlider );
00302 }
00303 }
00304
00305 function BrightnessChanged( GUIComponent Sender )
00306 {
00307 LOCAL float tmp;
00308 tmp = BrightnessSlider.GetValue() * 0.1;
00309 GetPlayerOwner().ConsoleCommand("Brightness "$tmp );
00310 }
00311
00312 function GammaChanged( GUIComponent Sender )
00313 {
00314 LOCAL float tmp;
00315 tmp = GammaSlider.GetValue() * 0.1;
00316 GetPlayerOwner().ConsoleCommand("Gamma "$tmp);
00317 }
00318
00319 function ContrastChanged( GUIComponent Sender )
00320 {
00321 LOCAL float tmp;
00322 tmp = ContrastSlider.GetValue() * 0.1;
00323 GetPlayerOwner().ConsoleCommand("Contrast "$tmp);
00324 }
00325
00326
00327
00328
00329
00330 defaultproperties
00331 {
00332 TitleText="Video Options"
00333 BrightnessText="Brightness"
00334 GammaText="Gamma"
00335 ContrastText="Contrast"
00336 DefaultText="Default"
00337 CenterText="CENTER"
00338 HCenterText="Horizontal"
00339 VCenterText="Vertical"
00340 ResText="Resolution"
00341 DepthText="Depth"
00342 sBackground(0)="XIIIMenuStart.VideoDecor1"
00343 sBackground(1)="XIIIMenuStart.VideoJones01A"
00344 sBackground(2)="XIIIMenuStart.VideoJones02A"
00345 sBackground(3)="XIIIMenuStart.VideoJones03A"
00346 sCenter="XIIIMenuStart.Boutonvideo2"
00347 UserBrightness=0.500000
00348 UserContrast=0.500000
00349 UserGamma=1.000000
00350 }
|