Skip to content

Commit dac752a

Browse files
committed
Refactor LightingStateManager
ProcessManager: Watch the runing Processes and call if found a match ProfileManager: Handle the switching between Profiles (Application) LightingStateManager: Rendering the Light Events Adding a change profile animation
1 parent 3272755 commit dac752a

17 files changed

Lines changed: 825 additions & 761 deletions

Project-Aurora/Plugin-Example/PluginMain.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public void ProcessManager(object manager)
3737
{
3838
if (manager is LightingStateManager)
3939
{
40-
((LightingStateManager)manager).RegisterLayerHandler(new LayerHandlerEntry("ExampleLayer", "Example Layer", typeof(ExampleLayerHandler)));
40+
((ProfileManager)manager).RegisterLayerHandler(new LayerHandlerEntry("ExampleLayer", "Example Layer", typeof(ExampleLayerHandler)));
4141
}
4242
}
4343
}

Project-Aurora/Project-Aurora/App.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public static void LogLine(this NLog.Logger logger, string text, Logging_Level l
112112

113113
//public static GameEventHandler geh;
114114
public static PluginManager PluginManager;
115-
public static LightingStateManager LightingStateManager;
115+
public static ProfileManager LightingStateManager;
116116
public static NetworkListener net_listener;
117117
public static Configuration Configuration;
118118
public static DeviceManager dev_manager;
@@ -353,7 +353,7 @@ protected override void OnStartup(StartupEventArgs e)
353353
}
354354

355355
Global.logger.Info("Loading Applications");
356-
(Global.LightingStateManager = new LightingStateManager()).Initialize();
356+
(Global.LightingStateManager = new ProfileManager()).Initialize();
357357

358358
if (Global.Configuration.GetPointerUpdates)
359359
{

Project-Aurora/Project-Aurora/ConfigUI.xaml.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ partial class ConfigUI : Window, INotifyPropertyChanged
4444
private bool settingsloaded = false;
4545
private bool shownHiddenMessage = false;
4646

47-
private string saved_preview_key = "";
47+
private string saved_preview_key = null;
48+
public string preview_key => saved_preview_key;
4849

4950
private Timer virtual_keyboard_timer;
5051
private Stopwatch recording_stopwatch = new Stopwatch();
@@ -64,7 +65,9 @@ public Profiles.Application FocusedApplication
6465
set
6566
{
6667
SetValue(FocusedApplicationProperty, value);
67-
Global.LightingStateManager.PreviewProfileKey = value != null ? value.Config.ID : string.Empty;
68+
saved_preview_key = value != null ? value.Config.ID : null;
69+
70+
Global.LightingStateManager.FocusedApplicationChanged(saved_preview_key);
6871
}
6972
}
7073

@@ -332,8 +335,6 @@ private void minimizeApp()
332335
shownHiddenMessage = true;
333336
}
334337

335-
Global.LightingStateManager.PreviewProfileKey = string.Empty;
336-
337338
//Hide Window
338339
System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, (System.Windows.Threading.DispatcherOperationCallback)delegate (object o)
339340
{
@@ -345,13 +346,12 @@ private void minimizeApp()
345346

346347
private void Window_Activated(object sender, EventArgs e)
347348
{
348-
Global.LightingStateManager.PreviewProfileKey = saved_preview_key;
349+
Global.LightingStateManager.FocusedApplicationChanged(saved_preview_key);
349350
}
350351

351352
private void Window_Deactivated(object sender, EventArgs e)
352353
{
353-
saved_preview_key = Global.LightingStateManager.PreviewProfileKey;
354-
Global.LightingStateManager.PreviewProfileKey = string.Empty;
354+
Global.LightingStateManager.FocusedApplicationChanged(null);
355355
}
356356

357357
private Image profile_add;

Project-Aurora/Project-Aurora/Controls/ColorZones.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ private void effect_settings_button_Click(object sender, RoutedEventArgs e)
168168
if (cz_list.SelectedItem != null)
169169
{
170170
EffectSettingsWindow effect_settings = new EffectSettingsWindow(((ColorZone)cz_list.SelectedItem).effect_config);
171-
effect_settings.preview_key = Global.LightingStateManager.PreviewProfileKey;
171+
172+
effect_settings.preview_key = ((ConfigUI)System.Windows.Application.Current.MainWindow).preview_key;
172173
effect_settings.EffectConfigUpdated += Effect_settings_EffectConfigUpdated;
173174

174175
effect_settings.ShowDialog();

Project-Aurora/Project-Aurora/Controls/EffectSettingsWindow.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,12 @@ private void accept_button_Click(object sender, RoutedEventArgs e)
122122

123123
private void Window_Activated(object sender, EventArgs e)
124124
{
125-
Global.LightingStateManager.PreviewProfileKey = preview_key;
125+
Global.LightingStateManager.FocusedApplicationChanged(null);
126126
}
127127

128128
private void Window_Deactivated(object sender, EventArgs e)
129129
{
130-
Global.LightingStateManager.PreviewProfileKey = null;
130+
Global.LightingStateManager.FocusedApplicationChanged(preview_key);
131131
}
132132

133133
private void effect_angle_ValueChanged(object sender, RoutedPropertyChangedEventArgs<object> e)

Project-Aurora/Project-Aurora/Profiles/Application.cs

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,10 @@ public class LightEventConfig : NotifyPropertyChangedEx
4444

4545
public LightEvent Event { get; set; }
4646

47-
public int? UpdateInterval { get; set; } = null;
48-
4947
public string IconURI { get; set; }
5048

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

53-
protected LightEventType? type = LightEventType.Normal;
54-
public LightEventType? Type
55-
{
56-
get { return type; }
57-
set
58-
{
59-
object old = type;
60-
object newVal = value;
61-
type = value;
62-
InvokePropertyChanged(old, newVal);
63-
}
64-
}
6551

6652
public bool EnableByDefault { get; set; } = true;
6753
public bool EnableOverlaysByDefault { get; set; } = true;
@@ -84,18 +70,7 @@ public class Application : ObjectSettings<ApplicationSettings>, IInit, ILightEve
8470
public bool IsEnabled { get { return Settings.IsEnabled; } }
8571
public bool IsOverlayEnabled { get { return Settings.IsOverlayEnabled; } }
8672
public event PropertyChangedExEventHandler PropertyChanged;
87-
protected LightEventType type;
88-
public LightEventType Type
89-
{
90-
get { return type; }
91-
protected set
92-
{
93-
object old = type;
94-
object newVal = value;
95-
type = value;
96-
InvokePropertyChanged(old, newVal);
97-
}
98-
}
73+
9974
#endregion
10075

10176
#region Internal Properties

Project-Aurora/Project-Aurora/Profiles/Desktop/Event_Desktop.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ public Event_Desktop() : base()
2525
public override void UpdateLights(EffectFrame frame)
2626
{
2727
var layers = new Queue<EffectLayer>(Application.Profile.Layers.Where(l => l.Enabled).Reverse().Select(l => l.Render(_game_state)));
28-
var overlayLayers = new Queue<EffectLayer>(Application.Profile.OverlayLayers.Where(l => l.Enabled).Reverse().Select(l => l.Render(_game_state)));
2928

3029
//Scripts before interactive and shortcut assistant layers
3130
//ProfilesManager.DesktopProfile.UpdateEffectScripts(layers);
@@ -43,6 +42,11 @@ public override void UpdateLights(EffectFrame frame)
4342
}
4443

4544
frame.AddLayers(layers.ToArray());
45+
}
46+
public override void UpdateOverlayLights(EffectFrame frame)
47+
{
48+
var overlayLayers = new Queue<EffectLayer>(Application.Profile.OverlayLayers.Where(l => l.Enabled).Reverse().Select(l => l.Render(_game_state)));
49+
4650
frame.AddOverlayLayers(overlayLayers.ToArray());
4751
}
4852

Project-Aurora/Project-Aurora/Profiles/LightEvent.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@
88

99
namespace Aurora.Profiles
1010
{
11-
public enum LightEventType
12-
{
13-
Normal,
14-
Underlay,
15-
Overlay
16-
}
1711

1812
public interface ILightEvent : IInit
1913
{

0 commit comments

Comments
 (0)