mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 20:06:33 +00:00
Profile editor - Redesigned adding/removing timeline segments
General module - Added some basic window information to the data model Profiles - Don't render when opacity is 0 Profile editor - Render non-selected layers in their main segment Profile editor - Condition editor fixes
This commit is contained in:
1 parent
732ee2f429
commit
64a1010100
39 files changed
+831
-261
No files matched your search
@@ -12,6 +12,7 @@ namespace Artemis.Plugins.LayerEffects.Filter
|
||||
"BlurOn"
|
||||
);
|
||||
AddLayerEffectDescriptor<DilateEffect>("Dilate", "A layer effect providing a dilation filter effect", "EyePlus");
|
||||
AddLayerEffectDescriptor<OpacityEffect>("Opacity", "A layer effect letting you change the opacity of all children", "Opacity");
|
||||
AddLayerEffectDescriptor<ErodeEffect>("Erode", "A layer effect providing an erode filter effect", "EyeMinus");
|
||||
AddLayerEffectDescriptor<GlowEffect>("Glow", "A layer effect providing a glow filter effect", "BoxShadow");
|
||||
AddLayerEffectDescriptor<GrayScaleEffect>("Gray-scale", "A layer effect providing a gray-scale filter effect", "InvertColors");
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Models.Profile.LayerProperties.Attributes;
|
||||
using Artemis.Core.Models.Profile.LayerProperties.Types;
|
||||
using Artemis.Core.Plugins.LayerEffect.Abstract;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Plugins.LayerEffects.Filter
|
||||
{
|
||||
public class OpacityEffect : LayerEffect<OpacityEffectProperties>
|
||||
{
|
||||
public override void EnableLayerEffect()
|
||||
{
|
||||
}
|
||||
|
||||
public override void DisableLayerEffect()
|
||||
{
|
||||
}
|
||||
|
||||
public override void Update(double deltaTime)
|
||||
{
|
||||
}
|
||||
|
||||
public override void PreProcess(SKCanvas canvas, SKImageInfo canvasInfo, SKPath renderBounds, SKPaint paint)
|
||||
{
|
||||
paint.Color = paint.Color.WithAlpha((byte) (Properties.Opacity.CurrentValue * 2.55f));
|
||||
}
|
||||
|
||||
public override void PostProcess(SKCanvas canvas, SKImageInfo canvasInfo, SKPath renderBounds, SKPaint paint)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class OpacityEffectProperties : LayerPropertyGroup
|
||||
{
|
||||
[PropertyDescription(Description = "The opacity of the shape", InputAffix = "%", MinInputValue = 0f, MaxInputValue = 100f)]
|
||||
public FloatLayerProperty Opacity { get; set; }
|
||||
|
||||
protected override void PopulateDefaults()
|
||||
{
|
||||
Opacity.DefaultValue = 100f;
|
||||
}
|
||||
|
||||
protected override void OnPropertiesInitialized()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
+17
-3
@@ -1,13 +1,27 @@
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Core.Plugins.Abstract.DataModels;
|
||||
using System.Diagnostics;
|
||||
using Artemis.Core.Plugins.Abstract.DataModels.Attributes;
|
||||
using Artemis.Plugins.Modules.General.DataModel.Windows;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Plugins.Modules.General
|
||||
namespace Artemis.Plugins.Modules.General.DataModel
|
||||
{
|
||||
public class GeneralDataModel : DataModel
|
||||
public class GeneralDataModel : Core.Plugins.Abstract.DataModels.DataModel
|
||||
{
|
||||
public TestDataModel TestDataModel { get; set; }
|
||||
public WindowsDataModel Windows { get; set; }
|
||||
|
||||
|
||||
public GeneralDataModel()
|
||||
{
|
||||
TestDataModel = new TestDataModel();
|
||||
Windows = new WindowsDataModel();
|
||||
}
|
||||
}
|
||||
|
||||
public class TestDataModel
|
||||
{
|
||||
public TestDataModel()
|
||||
{
|
||||
PlayerInfo = new PlayerInfo();
|
||||
IntsList = new List<int>();
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.Diagnostics;
|
||||
using Artemis.Core.Plugins.Abstract.DataModels.Attributes;
|
||||
using Artemis.Plugins.Modules.General.Utilities;
|
||||
|
||||
namespace Artemis.Plugins.Modules.General.DataModel.Windows
|
||||
{
|
||||
public class WindowDataModel
|
||||
{
|
||||
[DataModelIgnore]
|
||||
public Process Process { get; }
|
||||
|
||||
public WindowDataModel(Process process)
|
||||
{
|
||||
Process = process;
|
||||
WindowTitle = process.MainWindowTitle;
|
||||
ProcessName = process.ProcessName;
|
||||
|
||||
// Accessing MainModule requires admin privileges, this way does not
|
||||
ProgramLocation = WindowMonitor.GetProcessFilename(process);
|
||||
}
|
||||
|
||||
public string WindowTitle { get; set; }
|
||||
public string ProcessName { get; set; }
|
||||
public string ProgramLocation { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Artemis.Plugins.Modules.General.DataModel.Windows
|
||||
{
|
||||
public class WindowsDataModel
|
||||
{
|
||||
public WindowDataModel ActiveWindow { get; set; }
|
||||
public List<WindowDataModel> OpenWindows { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Interop;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.Abstract.ViewModels;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Plugins.Modules.General.DataModel;
|
||||
using Artemis.Plugins.Modules.General.DataModel.Windows;
|
||||
using Artemis.Plugins.Modules.General.Utilities;
|
||||
using Artemis.Plugins.Modules.General.ViewModels;
|
||||
using SkiaSharp;
|
||||
|
||||
@@ -13,6 +21,7 @@ namespace Artemis.Plugins.Modules.General
|
||||
private readonly PluginSettings _settings;
|
||||
private readonly Random _rand;
|
||||
|
||||
|
||||
public GeneralModule(PluginSettings settings)
|
||||
{
|
||||
_settings = settings;
|
||||
@@ -26,12 +35,19 @@ namespace Artemis.Plugins.Modules.General
|
||||
|
||||
public override void Update(double deltaTime)
|
||||
{
|
||||
DataModel.UpdatesDividedByFour += 0.25;
|
||||
DataModel.Updates += 1;
|
||||
DataModel.PlayerInfo.Position = new SKPoint(_rand.Next(100), _rand.Next(100));
|
||||
DataModel.TestDataModel.UpdatesDividedByFour += 0.25;
|
||||
DataModel.TestDataModel.Updates += 1;
|
||||
DataModel.TestDataModel.PlayerInfo.Position = new SKPoint(_rand.Next(100), _rand.Next(100));
|
||||
DataModel.TestDataModel.PlayerInfo.Health++;
|
||||
if (DataModel.TestDataModel.PlayerInfo.Health > 200)
|
||||
DataModel.TestDataModel.PlayerInfo.Health = 0;
|
||||
|
||||
DataModel.TestDataModel.IntsList[0] = _rand.Next();
|
||||
DataModel.TestDataModel.IntsList[2] = _rand.Next();
|
||||
|
||||
UpdateCurrentWindow();
|
||||
UpdateBackgroundWindows();
|
||||
|
||||
DataModel.IntsList[0] = _rand.Next();
|
||||
DataModel.IntsList[2] = _rand.Next();
|
||||
base.Update(deltaTime);
|
||||
}
|
||||
|
||||
@@ -41,8 +57,8 @@ namespace Artemis.Plugins.Modules.General
|
||||
DisplayIcon = "AllInclusive";
|
||||
ExpandsDataModel = true;
|
||||
|
||||
DataModel.IntsList = new List<int> {_rand.Next(), _rand.Next(), _rand.Next()};
|
||||
DataModel.PlayerInfosList = new List<PlayerInfo> {new PlayerInfo()};
|
||||
DataModel.TestDataModel.IntsList = new List<int> {_rand.Next(), _rand.Next(), _rand.Next()};
|
||||
DataModel.TestDataModel.PlayerInfosList = new List<PlayerInfo> {new PlayerInfo()};
|
||||
|
||||
var testSetting = _settings.GetSetting("TestSetting", DateTime.Now);
|
||||
}
|
||||
@@ -50,5 +66,36 @@ namespace Artemis.Plugins.Modules.General
|
||||
public override void DisablePlugin()
|
||||
{
|
||||
}
|
||||
|
||||
#region Open windows
|
||||
|
||||
private DateTime _lastBackgroundWindowsUpdate;
|
||||
|
||||
public void UpdateCurrentWindow()
|
||||
{
|
||||
var processId = WindowMonitor.GetActiveProcessId();
|
||||
if (DataModel.Windows.ActiveWindow == null || DataModel.Windows.ActiveWindow.Process.Id != processId)
|
||||
DataModel.Windows.ActiveWindow = new WindowDataModel(Process.GetProcessById(processId));
|
||||
}
|
||||
|
||||
public void UpdateBackgroundWindows()
|
||||
{
|
||||
// This is kinda slow so lets not do it very often and lets do it in a task
|
||||
if (DateTime.Now - _lastBackgroundWindowsUpdate < TimeSpan.FromSeconds(5))
|
||||
return;
|
||||
|
||||
_lastBackgroundWindowsUpdate = DateTime.Now;
|
||||
Task.Run(() =>
|
||||
{
|
||||
// All processes with a main window handle are considered open windows
|
||||
DataModel.Windows.OpenWindows = Process.GetProcesses()
|
||||
.Where(p => p.MainWindowHandle != IntPtr.Zero)
|
||||
.Select(p => new WindowDataModel(p))
|
||||
.Where(w => !string.IsNullOrEmpty(w.WindowTitle))
|
||||
.ToList();
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace Artemis.Plugins.Modules.General.Utilities
|
||||
{
|
||||
public static class WindowMonitor
|
||||
{
|
||||
public static int GetActiveProcessId()
|
||||
{
|
||||
var hWnd = GetForegroundWindow(); // Get foreground window handle
|
||||
GetWindowThreadProcessId(hWnd, out var processId);
|
||||
return (int) processId;
|
||||
}
|
||||
|
||||
public static string GetProcessFilename(Process p)
|
||||
{
|
||||
var capacity = 2000;
|
||||
var builder = new StringBuilder(capacity);
|
||||
var ptr = OpenProcess(ProcessAccessFlags.QueryLimitedInformation, false, p.Id);
|
||||
if (!QueryFullProcessImageName(ptr, 0, builder, ref capacity)) return string.Empty;
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern IntPtr GetForegroundWindow();
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
private static extern bool QueryFullProcessImageName([In] IntPtr hProcess, [In] int dwFlags, [Out] StringBuilder lpExeName, ref int lpdwSize);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
private static extern IntPtr OpenProcess(ProcessAccessFlags processAccess, bool bInheritHandle, int processId);
|
||||
|
||||
|
||||
[Flags]
|
||||
private enum ProcessAccessFlags : uint
|
||||
{
|
||||
QueryLimitedInformation = 0x00001000
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user