class LightMenu extends GUI2K4.MidGamePanel config(HideMut); // =================================================================Interface section var automated GUISectionBackground sb_ControlsAllMap, sb_Stats, sb_Tweaker; var automated moNumericEdit nu_Radius, nu_newRadius, nu_maxRadius, nu_LightCone, nu_LightPeriod, nu_LightBrightness, nu_LightHue, nu_LightSaturation, nu_LightEffect, nu_LightType; var automated MOCheckBox ch_Optimize, ch_RemoveFlickering, ch_FlickeringToStatic, ch_ActorShadows, ch_AttenByLife, ch_bCorona, ch_bDirectionalCorona, ch_bDynamicLight, ch_bLightingVisibility, ch_bSpecialLit; var automated GUIScrollTextBox lb_Actions; var automated GUIButton b_HideLights, b_OptAllLights, b_MakeAllLightVisible, b_DisableCoronas, b_SaveConfig, b_OptStatic, b_ClearLog; // ====================================================================End of interface section var transient array CachedLights; // Cached lights for checks, stats and etc. var transient array CachedTriggerLights; // Cached trigger lights just in case var transient array LightColors; // Unique light colors var bool bCached; // Prevents multiple caching var int maxRadius_L, maxRadius_TL; // Max radius for light sources(trigger light and lights) // ==========================================config variables var config bool bActorShadows, bAttenByLife, bLightingVisibility, bCorona, bDirectionalCorona, bSpecialLit, // Tweaker Optimize, RemoveFlickering, FlickeringToStatic; var config int NewRadius, maxRadius; var config byte byteRadius, byteLightBrightness, byteLightHue, byteLightSaturation, byteLightType, byteLightEffect, byteLightCone, byteLightPeriod; // ==========================================end of config variables var PlayerController PC; var bool IsUnlited, bConfigLoaded; simulated function InitComponent(GUIController MyController, GUIComponent MyOwner) { local GUIButton B; local string s; local int i; super.InitComponent(MyController,MyOwner); PC = PlayerOwner(); sb_Stats.ManageComponent(lb_Actions); sb_Stats.ManageComponent(b_ClearLog); sb_Tweaker.ManageComponent(nu_newRadius); sb_Tweaker.ManageComponent(nu_maxRadius); sb_Tweaker.ManageComponent(ch_Optimize); sb_Tweaker.ManageComponent(ch_RemoveFlickering); sb_Tweaker.ManageComponent(ch_FlickeringToStatic); sb_Tweaker.ManageComponent(b_HideLights); sb_Tweaker.ManageComponent(b_DisableCoronas); sb_Tweaker.ManageComponent(b_OptStatic); sb_ControlsAllMap.ManageComponent(nu_Radius); sb_ControlsAllMap.ManageComponent(nu_LightCone); sb_ControlsAllMap.ManageComponent(nu_LightPeriod); sb_ControlsAllMap.ManageComponent(nu_LightBrightness); sb_ControlsAllMap.ManageComponent(nu_LightHue); sb_ControlsAllMap.ManageComponent(nu_LightSaturation); sb_ControlsAllMap.ManageComponent(nu_LightEffect); sb_ControlsAllMap.ManageComponent(nu_LightType); sb_ControlsAllMap.ManageComponent(ch_ActorShadows); sb_ControlsAllMap.ManageComponent(ch_AttenByLife); sb_ControlsAllMap.ManageComponent(ch_bCorona); sb_ControlsAllMap.ManageComponent(ch_bDirectionalCorona); sb_ControlsAllMap.ManageComponent(ch_bDynamicLight); sb_ControlsAllMap.ManageComponent(ch_bLightingVisibility); sb_ControlsAllMap.ManageComponent(ch_bSpecialLit); sb_ControlsAllMap.ManageComponent(b_OptAllLights); sb_ControlsAllMap.ManageComponent(b_SaveConfig); sb_ControlsAllMap.ManageComponent(b_MakeAllLightVisible); // For resizing buttons s = GetSizingCaption(); for (i = 0; i < Controls.length; i++) { B = GUIButton(Controls[i]); if (B != None) { B.bAutoSize = true; B.SizingCaption = s; B.AutoSizePadding.HorzPerc = 0.04; B.AutoSizePadding.VertPerc = 0.8; } } ch_ActorShadows.Checked(bActorShadows); ch_AttenByLife.Checked(bAttenByLife); nu_Radius.SetValue(byteRadius); ch_bLightingVisibility.Checked(bLightingVisibility); ch_bCorona.Checked(bCorona); ch_bDirectionalCorona.Checked(bDirectionalCorona); nu_LightBrightness.SetValue(byteLightBrightness); nu_LightHue.SetValue(byteLightHue); nu_LightSaturation.SetValue(byteLightSaturation); ch_bSpecialLit.Checked(bSpecialLit); nu_LightType.SetValue(byteLightType); nu_LightEffect.SetValue(byteLightEffect); nu_LightCone.SetValue(byteLightCone); nu_LightPeriod.SetValue(byteLightPeriod); } function string GetSizingCaption() { local int i; local string S; for (i = 0; i < Controls.length; i++) if (GUIButton(Controls[i]) != None) if (S == "" || Len(GUIButton(Controls[i]).Caption) > Len(S)) S = GUIButton(Controls[i]).Caption; return S; } function ShowPanel(bool bShow) { super.ShowPanel(bShow); if (bShow) CacheLights(); } event Opened(GUIComponent Sender) { super.Opened(Sender); // Caching lights if (!bCached) { CacheLights(); } if (!bConfigLoaded) { LoadLightConfig(); bConfigLoaded = True; } } simulated function bool ButtonClicked(GUIComponent Sender) { // Caching lights if (!bCached) { CacheLights(); } switch (Sender) { case b_HideLights: OptLights(nu_newRadius.GetValue(), nu_maxRadius.GetValue(), ch_Optimize.IsChecked(), ch_RemoveFlickering.IsChecked(), ch_FlickeringToStatic.IsChecked()); break; case b_OptAllLights: OptAllLights(); break; case b_MakeAllLightVisible: AllLightVisible(); break; case b_DisableCoronas: RemoveCoronas(); break; case b_SaveConfig: SaveLightConfig(); break; case b_OptStatic: OptimizeStaticMeshes(); break; case b_ClearLog: lb_Actions.SetContent(""); break; } // Get lighting statistics StatLights(); return true; } simulated function SaveLightConfig() { bActorShadows = ch_ActorShadows.IsChecked(); bAttenByLife = ch_AttenByLife.IsChecked(); byteRadius = nu_Radius.GetValue(); bLightingVisibility = ch_bLightingVisibility.IsChecked(); bCorona = ch_bCorona.IsChecked(); bDirectionalCorona = ch_bDirectionalCorona.IsChecked(); byteLightBrightness = nu_LightBrightness.GetValue(); byteLightHue = nu_LightHue.GetValue(); byteLightSaturation = nu_LightSaturation.GetValue(); bSpecialLit = ch_bSpecialLit.IsChecked(); byteLightType = nu_LightType.GetValue(); byteLightEffect = nu_LightEffect.GetValue(); byteLightCone = nu_LightCone.GetValue(); byteLightPeriod = nu_LightPeriod.GetValue(); NewRadius = nu_newRadius.GetValue(); maxRadius = nu_maxRadius.GetValue(); Optimize = ch_Optimize.IsChecked(); RemoveFlickering = ch_RemoveFlickering.IsChecked(); FlickeringToStatic = ch_FlickeringToStatic.IsChecked(); SaveConfig(); } simulated function LoadLightConfig() { ch_ActorShadows.Checked(bActorShadows); ch_AttenByLife.Checked(bAttenByLife); nu_Radius.SetValue(byteRadius); ch_bLightingVisibility.Checked(bLightingVisibility); ch_bCorona.Checked(bCorona); ch_bDirectionalCorona.Checked(bDirectionalCorona); nu_LightBrightness.SetValue(byteLightBrightness); nu_LightHue.SetValue(byteLightHue); nu_LightSaturation.SetValue(byteLightSaturation); ch_bSpecialLit.Checked(bSpecialLit); nu_LightType.SetValue(byteLightType); nu_LightEffect.SetValue(byteLightEffect); nu_LightCone.SetValue(byteLightCone); nu_LightPeriod.SetValue(byteLightPeriod ); nu_newRadius.SetValue(NewRadius); nu_maxRadius.SetValue(maxRadius); ch_Optimize.Checked(Optimize); ch_RemoveFlickering.Checked(RemoveFlickering); ch_FlickeringToStatic.Checked(FlickeringToStatic); } simulated function AllLightVisible() // Toggle lights visibility { local int i; for (i=0;i 0 || CachedTriggerLights.Length > 0) bCached = True; } // Clear cache simulated function ClearCache() { CachedLights.Remove(0,CachedLights.Length); CachedTriggerLights.Remove(0,CachedTriggerLights.Length); bCached = False; } // Get max radius of light sources and triggerlight simulated function MaxRad(out int MRad, out int TlMRad) { local int i; if (CachedLights.length == 0) return; MRad = CachedLights[0].LightRadius; // Find max radius for (i=0;i MRad) { MRad = CachedLights[i].LightRadius ; } } if (CachedTriggerLights.length == 0) return; TlMRad = CachedTriggerLights[0].LightRadius; // Find max radius for(i=0;i TlMRad) { TlMRad = CachedLights[i].LightRadius; } } } simulated function GetUniqueColorsLights() { local int i, k, count; local bool bAlreadyIsIn; if (CachedLights.Length == 0) return; if (LightColors.Length == 0) { LightColors[0] = CachedLights[0].LightHue; count++; } for (i=0; i < CachedLights.length; i++) { for (k=0; k < LightColors.length; k++) // Finding unique color { if (LightColors[k] == CachedLights[i].LightHue) { bAlreadyIsIn = True; break; // Already having dat color } } if (!bAlreadyIsIn) { LightColors[count] = CachedLights[i].LightHue; // Adding unique light count++; } bAlreadyIsIn = False; // Next iteration } } // Statistics simulated function StatLights() // Get light statistics { local int i, maxRadiusCountL, maxRadiusCountTL, SpecialLit_CountL, SpecialLit_CountTL; if (maxRadius_TL==0 || maxRadius_L==0) { MaxRad(maxRadius_L, maxRadius_TL); } if (CachedTriggerLights.length > 0) { for (i=0; i < cachedTriggerLights.length; i++) { if (CachedTriggerLights[i].bSpecialLit) SpecialLit_CountTL++; if (CachedTriggerLights[i].LightRadius == maxRadius_TL) maxRadiusCountTL++; } } if (CachedLights.length == 0) // if no lights on map == fuckoff return; for (i=0; i < CachedLights.length; i++) { if (CachedLights[i].bSpecialLit) SpecialLit_CountL++; if (CachedLights[i].LightRadius == maxRadius_L) maxRadiusCountL++; } LightColors.Length = 0; GetUniqueColorsLights(); lb_Actions.Addtext("There are" @ CachedLights.length @ "light sources" @ "and" @ cachedTriggerLights.length @ "Trigger light sources"); lb_Actions.Addtext("Max Radius for light source is " @ maxRadius_L @ ". Light sources that uses max radius:" @ maxRadiusCountL @ "Max Radius for triggerlight source is " @ maxRadius_TL @ ". TriggerLight sources that uses max radius:" @ maxRadiusCountTL); lb_Actions.Addtext("Detected" @ LightColors.length @ "unique lights"); lb_Actions.Addtext("Detected" @ SpecialLit_CountL @ " SpecialLit lights" @ "Detected" @ SpecialLit_CountTL @ " SpecialLit triggerlights"); } // =======Lights // Light Optimization simulated function OptLights(Int Radius, Int maxRadius, bool Optimize, bool RemoveFlickering, bool FlickeringToStatic) { local Light LE; local TriggerLight TL; local int i, count; if (Radius == 0 || maxRadius == 0) return; forEach AllObjects (class'Light', LE) { if (LE.LightRadius > maxRadius) { LE.bSpecialLit = Optimize; LE.LightRadius = Radius; i++; } if (RemoveFlickering) { switch (LE.LightType) { case LT_Pulse: // 3 Laggy types of lights LE.LightType = LT_Steady; // Replace this to steady light count++; if (FlickeringToStatic) { LE.bSpecialLit = True; LE.bLightingVisibility = False; } break; case LT_Blink: LE.LightType = LT_Steady; // Replace this to steady light count++; if (FlickeringToStatic) { LE.bSpecialLit = True; LE.bLightingVisibility = False; } break; case LT_Flicker: LE.LightType = LT_Steady; // Replace this to steady light count++; if (FlickeringToStatic) { LE.bSpecialLit = True; LE.bLightingVisibility = False; } break; default: break; } } LE.bLightChanged=True; // Recalculate light now if (LE.bStatic) LE.ResetStaticFilterState(); } forEach AllObjects (class'TriggerLight', TL) { if (TL.LightRadius > maxRadius) { TL.bSpecialLit = Optimize; TL.LightRadius = Radius; i++; } if (RemoveFlickering) { switch (TL.LightType) { case LT_Pulse: // 3 Laggy types of lights TL.LightType = LT_Steady; // Replace this to steady light TL.InitialState = ''; count++; if (FlickeringToStatic) { TL.bSpecialLit = True; TL.bLightingVisibility = False; } break; case LT_Blink: TL.LightType = LT_Steady; // Replace this to steady light TL.InitialState = ''; count++; if (FlickeringToStatic) { TL.bSpecialLit = True; TL.bLightingVisibility = False; } break; case LT_Flicker: TL.LightType = LT_Steady; // Replace this to steady light TL.InitialState = ''; count++; if (FlickeringToStatic) { TL.bSpecialLit = True; TL.bLightingVisibility = False; } break; default: break; } } TL.bLightChanged=True; // Recalculate light now if (TL.bStatic) TL.ResetStaticFilterState(); } if (Optimize) lb_Actions.Addtext("Laggy lights are now fully static."); lb_Actions.Addtext("Radius for " @ i @ " lights set to " @ Radius @ ".Removed" @ count @ " flickering/pulsing/blinking light sources"); foreach AllObjects(class'Light', LE) if (LE.bLightChanged) LE.bLightChanged = False; } // RemoveCoronas simulated function RemoveCoronas() { local Light tempL; // Corona will be rendered because map author decide to force dis. No freedom for players... // Somehow this slow down Mesh lighting quite a bit(x2, x3)... forEach AllObjects (class'Light', tempL) { if(tempL.bCorona == true) { tempL.bCorona = false; if(tempL.bStatic) tempL.ResetStaticFilterState(); } } lb_Actions.Addtext("All coronas disabled!"); } simulated function OptimizeStaticMeshes() { local StaticMeshActor SMA; local Decoration Deco; IsUnlited = !IsUnlited; foreach AllObjects(class'StaticMeshActor', SMA) { SMA.bUnlit = IsUnlited; SMA.ResetStaticFilterstate(); } foreach AllObjects(class'Decoration', Deco) { Deco.bUnlit = IsUnlited; if (Deco.bStatic) Deco.ResetStaticFilterstate(); } } simulated function OptAllLights() { local int i; local light L; for (i=0; i