Skip to content
This repository has been archived by the owner on Aug 27, 2020. It is now read-only.

Commit

Permalink
Removed redundant LightEventType code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Wibble199 committed May 6, 2020
1 parent b748be0 commit 5aa7a35
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 101 deletions.
3 changes: 0 additions & 3 deletions Project-Aurora/Project-Aurora/Profiles/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ public class LightEventConfig : INotifyPropertyChanged

public HashSet<string> ExtraAvailableLayers { get; set; } = new HashSet<string>();

public LightEventType? Type { get; set; } = LightEventType.Normal;

public bool EnableByDefault { get; set; } = true;
public bool EnableOverlaysByDefault { get; set; } = true;

Expand All @@ -74,7 +72,6 @@ public class Application : ObjectSettings<ApplicationSettings>, IInit, ILightEve
public Type GameStateType { get { return Config.GameStateType; } }
public bool IsEnabled { get { return Settings.IsEnabled; } }
public bool IsOverlayEnabled { get { return Settings.IsOverlayEnabled; } }
public LightEventType Type { get; set; }
#endregion

#region Internal Properties
Expand Down
100 changes: 2 additions & 98 deletions Project-Aurora/Project-Aurora/Profiles/LightingStateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ public class LightingStateManager : ObjectSettings<ProfilesManagerSettings>, IIn

public Desktop.Desktop DesktopProfile { get { return (Desktop.Desktop)Events["desktop"]; } }

private List<string> Underlays = new List<string>();
private List<string> Normal = new List<string>();
private List<string> Overlays = new List<string>();

private List<ILightEvent> StartedEvents = new List<ILightEvent>();
private List<ILightEvent> UpdatedEvents = new List<ILightEvent>();

Expand Down Expand Up @@ -266,55 +262,6 @@ public bool RegisterProfile(LightEventConfig config)
return RegisterEvent(new Application(config));
}

private List<string> GetEventTable(LightEventType type)
{
List<string> events;
switch (type)
{
case LightEventType.Normal:
events = Normal;
break;
case LightEventType.Overlay:
events = Overlays;
break;
case LightEventType.Underlay:
events = Underlays;
break;
default:
throw new NotImplementedException();
}
return events;
}

private bool InsertLightEvent(ILightEvent lightEvent, LightEventType? old = null)
{
LightEventType type = lightEvent.Config.Type ?? LightEventType.Normal;
lightEvent.Config.Type = type;

if (old == null)
{
lightEvent.Config.PropertyChanged += LightEvent_PropertyChanged;
}
else
{
var oldEvents = GetEventTable((LightEventType)old);
oldEvents.Remove(lightEvent.Config.ID);
}

var events = GetEventTable(type);

events.Add(lightEvent.Config.ID);

return true;
}

private void LightEvent_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
ILightEvent lightEvent = (ILightEvent)sender;
if (e.PropertyName.Equals(nameof(LightEventConfig.Type)))
InsertLightEvent(lightEvent);
}

public bool RegisterEvent(ILightEvent @event)
{
string key = @event.Config.ID;
Expand Down Expand Up @@ -345,8 +292,6 @@ public bool RegisterEvent(ILightEvent @event)
Global.Configuration.ProfileOrder.Add(key);
}

this.InsertLightEvent(@event);

if (Initialized)
@event.Initialize();

Expand Down Expand Up @@ -646,51 +591,10 @@ private void Update()
else
Global.dev_manager.InitializeOnce();

if (Global.Configuration.OverlaysInPreview || !preview)
{
foreach (var underlay in Underlays)
{
ILightEvent @event = Events[underlay];
if (@event.IsEnabled && (@event.Config.ProcessNames == null || ProcessUtils.AnyProcessExists(@event.Config.ProcessNames)))
UpdateEvent(@event, newFrame);
}
}

//Need to do another check in case Desktop is disabled or the selected preview is disabled
if (profile.IsEnabled)
UpdateEvent(profile, newFrame);

if (Global.Configuration.OverlaysInPreview || !preview)
{
// Update any overlays registered in the Overlays array. This includes applications with type set to Overlay and things such as skype overlay
foreach (var overlay in Overlays)
{
ILightEvent @event = Events[overlay];
if (@event.IsEnabled && (@event.Config.ProcessNames == null || ProcessUtils.AnyProcessExists(@event.Config.ProcessNames)))
UpdateEvent(@event, newFrame);
}

// Update any overlays that are timer-based (e.g. the volume overlay that appears for a few seconds at a time)
TimedListObject[] overlay_events = overlays.ToArray();
foreach (TimedListObject evnt in overlay_events)
{
if ((evnt.item as LightEvent).IsEnabled)
UpdateEvent((evnt.item as LightEvent), newFrame);
}

// Update any applications that have overlay layers if that application is open
var events = GetOverlayActiveProfiles().ToList();

//Add the Light event that we're previewing to be rendered as an overlay
if (preview && Global.Configuration.OverlaysInPreview && !events.Contains(profile))
events.Add(profile);

foreach (var @event in events)
@event.UpdateOverlayLights(newFrame);

UpdateIdleEffects(newFrame);
}

Global.effengine.PushFrame(newFrame);

StopUnUpdatedEvents();
Expand All @@ -707,13 +611,13 @@ public ILightEvent GetCurrentProfile(out bool preview) {
preview = false;

//TODO: GetProfile that checks based on event type
if ((tempProfile = GetProfileFromProcessData(process_name, process_title)) != null && tempProfile.Config.Type == LightEventType.Normal && tempProfile.IsEnabled)
if ((tempProfile = GetProfileFromProcessData(process_name, process_title)) != null && tempProfile.IsEnabled)
profile = tempProfile;
else if ((tempProfile = GetProfileFromProcessName(previewModeProfileKey)) != null) //Don't check for it being Enabled as a preview should always end-up with the previewed profile regardless of it being disabled
{
profile = tempProfile;
preview = true;
} else if (Global.Configuration.allow_wrappers_in_background && Global.net_listener != null && Global.net_listener.IsWrapperConnected && ((tempProfile = GetProfileFromProcessName(Global.net_listener.WrappedProcess)) != null) && tempProfile.Config.Type == LightEventType.Normal && tempProfile.IsEnabled)
} else if (Global.Configuration.allow_wrappers_in_background && Global.net_listener != null && Global.net_listener.IsWrapperConnected && ((tempProfile = GetProfileFromProcessName(Global.net_listener.WrappedProcess)) != null) && tempProfile.IsEnabled)
profile = tempProfile;

profile = profile ?? DesktopProfile;
Expand Down

0 comments on commit 5aa7a35

Please sign in to comment.